<<<<<<< HEAD
<<<<<<< HEAD
 //1.公用样式
 require('../../assets/css/index.js')
 //当前页面样式
 require('./Inforrevise.less')

    //2.公用js
let dom=require('../../utils/dom.js');
// let http=require('../../utils/http.js');
let https=require('../../utils/https.js');

    //3.当前页面效果
// console.log(dom);
//相当于文档加载事件
dom.ready(function(){
let Fallback=document.querySelector('.Fallback');
let Image=document.querySelector('#Image');
let upload=document.querySelector('#upload');


    // 返回功能
Fallback.addEventListener('click',function(){
    window.history.go(-1);
})
// 头像的点击事件
Image.addEventListener('click',function(){
    // console.log(111)
    upload.click();    //同时执行input框的点击事件
 
})
            
upload.addEventListener('change',function(){

   
    //需要把索引为0里面的东西全部取出来
    https.uploadFile('file',this.files[0],'/api/shared/uploadPortrait1',function(res){
        if(res.errno==0){
            //    把成功获取的图像回填到网页中
            Image.src=https.BASE_URL +res.data.url
        }
    })
       
   
  
  
  
  
  
  
  
  
  
=======
=======
>>>>>>> wl
//1.公用样式
require('../../assets/css/index.js')
//当前页面样式
require('./Inforrevise.less')

//2.公用js
let dom = require('../../utils/dom.js');
// let http=require('../../utils/http.js');
let https = require('../../utils/https.js');

//3.当前页面效果
// console.log(dom);
//相当于文档加载事件
dom.ready(function () {
    let Fallback = document.querySelector('.Fallback');
    let Image = document.querySelector('#Image');
    let upload = document.querySelector('#upload');
    let showPicker = dom.getById('#showPicker')
    let showDatePicker = dom.getById('#showDatePicker')
    let gender = dom.getById('#gender');
    let xing = dom.getById('#xing')
    let showCityPicker = dom.getById('#showCityPicker')
    let seti = dom.getById('#seti');
    let introduce = dom.getById('.introduce');
    let zero = dom.getById('.zero')
  let Tjbtn=dom.getById('#SaveinformationBtn')
  let username=dom.getById('#username') 
    // 返回功能
    Fallback.addEventListener('click', function () {
        window.history.go(-1);
    })
    
    // 头像的点击事件
    Image.addEventListener('click', function () {
        // console.log(111)
        upload.click();    //同时执行input框的点击事件

    })
    let ulr="";
    upload.addEventListener('change', function () {


        //需要把索引为0里面的东西全部取出来
        https.uploadFile('file', this.files[0], '/api/shared/uploadPortrait1', function (res) {
            if (res.errno == 0) {
                //    把成功获取的图像回填到网页中
                Image.src = https.BASE_URL + res.data.url;
                ulr=res.data.url;
            }
        })

    })

    // 
    // 性别
    let genderID=0;
    showPicker.addEventListener('click', function () {
        weui.picker([{
            label: '男',
            value: 0
        }, {
            label: '女',
            value: 1
        }], {
                onConfirm: function (result) {
                    // console.log(result[0].label);
                    gender.textContent = result[0].label;
                    genderID=result[0].value;
                },
                title: '性别'
            });

    })
    // 生日
    let birsID='';
    showDatePicker.addEventListener('click', function () {
        weui.datePicker({
            start: 1990,
            end: new Date().getFullYear(),
            onConfirm: function (result) {
                let year = result.map(function (v, i) {
                    return v.value < 10 ? '0' + v.value : v.value
                }).join('-')
                // console.log(year);
                day.innerText = year
            },
            title: '请选择日期'
        });

    })
    // 省份
    let num = '';
    showShengPicker.addEventListener('click', function () {
        https.get('/api/shared/province', function (res) {
            // console.log(res)
           
            if (res.errno == 0) {
                // console.log(res.data)
                let sheng = res.data.map(function (v, i) {


                    return {
                        label: v.name,
                        value: v.id
                    }

                })
                // console.log(sheng)
                weui.picker(sheng, {
                    onConfirm: function (result) {
                        // console.log(result[0]);
                        xing.textContent = result[0].label;

                        num = result[0].value
                        console.log(num)
                    },
                    title: '省份'

                });
            }
<<<<<<< HEAD
>>>>>>> wl
=======
>>>>>>> wl




<<<<<<< HEAD
<<<<<<< HEAD

})





        
})
=======
=======
>>>>>>> wl
        })



    })

    // 城市
    let cityID='';
    showCityPicker.addEventListener('click', function () {
        https.get('/api/shared/city?provinceId=' + num, function (res) {
            console.log(res)

            if (res.errno == 0) {
                let chengshi = res.data.map(function (v, i) {
                    return {
                        label: v.name,
                        value: v.id
                    }
                })
                weui.picker(chengshi, {
                    onConfirm: function (result) {
                        // console.log(result[0]);

                        seti.textContent = result[0].label;
                        cityID=result[0].value;
                    }
                })
            }

        })

    })

    // 个人简介
    introduce.addEventListener('input',function(){
       zero.textContent=this.value.length;
       if( zero.textContent>=200){
        introduce.value=(this.value).substr(0,199)
       }
    //    console.log(this.value)
    })


    
    // 提交
    SaveinformationBtn.addEventListener('click',function(){

        // let  numss={
        //     nickName:username.value,
        //     gender:genderID,
        //     birthday: day.innerText,
        //     provinceId:num,
        //     cityID:cityID,
        //     imgUrl:ulr,
        //     sign: introduce.value
        // }
        //     console.log(numss)



          https.post('/api/user/changeInfo',{
            nickName:username.value,
            gender:genderID,
            birthday: day.innerText,
            provinceId:num,
            cityID:cityID,
            imgUrl:ulr,
            sign: introduce.value

          },function(res){

            console.log(res);
            if(res.errno==0){
                window.location.href='mine.html'
            }

          })



    })
})


<<<<<<< HEAD
>>>>>>> wl
=======
>>>>>>> wl
